//
//  RowsModel.swift
//  Pods
//
//  Created by eme on 2017/4/10.
//
//

import UIKit
import ModelProtocol
import NetWorkCore
import SwiftyJSON

class RowsModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kRowsMlevelKey: String = "mlevel"
    internal let kRowsMurlKey: String = "murl"
    internal let kRowsMtimeKey: String = "mtime"
    internal let kRowsMsgKey: String = "msg"
    internal let kRowsMopentitleKey: String = "mopentitle"
    internal let kRowsMpicKey: String = "mpic"
    internal let kRowsMidKey: String = "mid"
    internal let kRowsReadabledKey: String = "readabled"
    internal let kRowsMtitleKey: String = "mtitle"
    internal let kRowsPmidKey: String = "pmid"
    internal let kRowsMtoponeKey: String = "mtopone"
    internal let kRowsAdvparamsKey: String = "advparams"
    
    
    // MARK: 属性
    var mlevel: String
    var murl: String
    var mtime: String
    var msg: String
    var mopentitle: String
    var mpic: String
    var mid: Int
    var readabled: String
    var mtitle: String
    var pmid: String
    var mtopone: String
    var advparams: String
    
    
    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
    required  init?(json: JSON) {
        mlevel = json[kRowsMlevelKey].stringValue
        murl = json[kRowsMurlKey].stringValue
        mtime = json[kRowsMtimeKey].stringValue
        msg = json[kRowsMsgKey].stringValue
        mopentitle = json[kRowsMopentitleKey].stringValue
        mpic = json[kRowsMpicKey].stringValue
        mid = json[kRowsMidKey].intValue
        readabled = json[kRowsReadabledKey].stringValue
        mtitle = json[kRowsMtitleKey].stringValue
        pmid = json[kRowsPmidKey].stringValue
        mtopone = json[kRowsMtoponeKey].stringValue
        advparams = json[kRowsAdvparamsKey].stringValue
        
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    internal func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]

        dictionary.updateValue(mlevel as AnyObject, forKey: kRowsMlevelKey)
    
    
        dictionary.updateValue(murl as AnyObject, forKey: kRowsMurlKey)
    
        dictionary.updateValue(mtime as AnyObject, forKey: kRowsMtimeKey)
    
    
        dictionary.updateValue(msg as AnyObject, forKey: kRowsMsgKey)
   
        dictionary.updateValue(mopentitle as AnyObject, forKey: kRowsMopentitleKey)
    
    
        dictionary.updateValue(mpic as AnyObject, forKey: kRowsMpicKey)
    
        dictionary.updateValue(mid as AnyObject, forKey: kRowsMidKey)
    
        dictionary.updateValue(readabled as AnyObject, forKey: kRowsReadabledKey)
    
        dictionary.updateValue(mtitle as AnyObject, forKey: kRowsMtitleKey)
    
        dictionary.updateValue(pmid as AnyObject, forKey: kRowsPmidKey)
    
        dictionary.updateValue(mtopone as AnyObject, forKey: kRowsMtoponeKey)
    
        dictionary.updateValue(advparams as AnyObject, forKey: kRowsAdvparamsKey)
        
        
        return dictionary
    }
    
    
}
